# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-desmume
pkgver=0.0.1.9
_realname=Matrix
pkgrel=1
pkgdesc="DESMuME GameClient for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.desmume"
arch="x86 x86_64 aarch64 armv7" # kodi
license="GPL-2.0-or-later"
makedepends="cmake libretro-desmume kodi-dev"
depends="kodi-game-libretro libretro-desmume"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.desmume/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.desmume-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi \
		-DUSE_LTO=1
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -f "$pkgdir"/usr/lib/kodi/addons/game.libretro.desmume/game.libretro.desmume.so
	ln -s /usr/lib/libretro/desmume_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.desmume/game.libretro.desmume.so
}

sha512sums="222cad6c58e0dd4bac6b124cf44afa659f6f7ed42af95187548873d1eb7348589af76e7a2b91724e5bc78049bfe52bfe818c003bfb02d213616bb45416934fab  kodi-game-libretro-desmume-0.0.1.9-Matrix.tar.gz"
